<template>
  <div class="index_app">
    <div class="index_banner">
      <Header class="navlist" />
      <Banner class="banner" />
    </div>
  </div>
</template>

<script>
import Header from "~/components/common/header.vue";
import Banner from "~/components/common/banner.vue";
import { location } from "../static/js/Location";
export default {
  data() {
    return {
      timer: null,
      // locatName: "",
      citys: {},
    };
  },

  head() {
    return {
      meta: [
        {
          name: "知崖主页",
          content:
            "近期电影天堂(查看最近的电影院的播放信息)  音乐播放中心  小说阅读与创作中心 学习文档交流社区  优秀项目展示社区",
        },
      ],
    };
  },

  async asyncData({ $axios, store, error }) {},

  mounted() {
    if (this.$store.state.citys == null) {
      this.getLocation(); // 调用获取地理位置
    }
  },
  components: {
    Header,
    Banner,
  },

  methods: {
    /**获取地图定位 1*/
    getLocation() {
      let _that = this;
      let geolocation = location.initMap("map-container"); //定位
      AMap.event.addListener(geolocation, "complete", async (result) => {
        let locatName = result.addressComponent.city.replace("市", "");

        let data1 = await this.$axios({
          url: "/gateway?k=6278928",
          method: "get",
          headers: {
            "X-Client-Info":
              '{"a":"3000","ch":"1002","v":"5.0.4","e":"1606962163804279870816257"}',
            "X-Host": "mall.film-ticket.city.list",
          },
        });
        this.citys = data1.data.cities.find((item) => {
          return item.name == locatName;
        });
        //保存到 vuex
        this.$store.commit("setcitys", this.citys);
      });
    },
  },
};
</script>

<style scoped lang="less">
.index_app {
  min-height: 3000px;
  .index_banner {
    height: 722px;
    background-color: #198ede;
    .navlist {
      width: 100%;
      position: absolute;
      top: 0;
      left: 0;
      z-index: 999;
    }
    .banner {
    }
  }
}

img {
  max-width: 100px;
}
</style>
